<template>
  <el-dropdown id="size-select" trigger="click" @command="handleSetSize">
    <div>
      <svg class="icon" aria-hidden="true" font-size="40px">
        <use xlink:href="#iconshiliangzhinengduixiang" />
      </svg>
    </div>

    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item v-for="item of sizeOptions" :key="item.value" :disabled="size === item.value" :command="item.value">
          {{ item.label }}
        </el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>

<script setup lang="ts">
import { useStore } from '@/store'
import { AppActionTypes } from '@/store/modules/app/action-types'
import { ElMessage } from 'element-plus'
import { computed, ref } from 'vue'
const store = useStore()

const handleSetSize = (size: string) => {
  store.dispatch(AppActionTypes.ACTION_SET_SIZE, size)
  ElMessage.success('Switch Size Success')
}

const size = computed(() => {
  return store.state.app.size
})

const sizeOptions = ref([
  { label: 'Default', value: "default" },
  { label: 'Medium', value: "medium" },
  { label: 'Small', value: "small" },
  { label: 'Mini', value: "mini" },
])
</script>

<style lang="scss" scoped>
</style>
